home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -websites- / whdload / docs / autodoc.txt < prev    next >
Text File  |  1999-12-06  |  77KB  |  1,997 lines

  1. TABLE OF CONTENTS
  2.  
  3. WHDLoad/--Overview--
  4. WHDLoad/resload_Abort
  5. WHDLoad/resload_Control
  6. WHDLoad/WHDLTAG_CBAF_SET
  7. WHDLoad/WHDLTAG_CBSWITCH_SET
  8. WHDLoad/WHDLTAG_IOERR_GET
  9. WHDLoad/resload_CRC16
  10. WHDLoad/resload_Decrunch
  11. WHDLoad/resload_Delay
  12. WHDLoad/resload_DeleteFile
  13. WHDLoad/resload_DiskLoad
  14. WHDLoad/resload_DiskLoadDev
  15. WHDLoad/resload_FlushCache
  16. WHDLoad/resload_GetFileSize
  17. WHDLoad/resload_ListFiles
  18. WHDLoad/resload_LoadFile
  19. WHDLoad/resload_LoadFileDecrunch
  20. WHDLoad/resload_LoadFileOffset
  21. WHDLoad/resload_Patch
  22. WHDLoad/resload_ProtectRead
  23. WHDLoad/resload_ProtectReadWrite
  24. WHDLoad/resload_ProtectRemove
  25. WHDLoad/resload_ProtectSMC
  26. WHDLoad/resload_ProtectWrite
  27. WHDLoad/resload_Relocate
  28. WHDLoad/resload_SaveFile
  29. WHDLoad/resload_SaveFileOffset
  30. WHDLoad/resload_SetCACR
  31. WHDLoad/resload_SetCPU
  32. WHDLoad.Slave/--Overview--
  33.  
  34. WHDLoad/--Overview--
  35.  
  36. The calling conventions for all functions are similar to the OS-Library-
  37. concept. Parameters are provided in registers (except "resload_Abort"),
  38. return codes comes in D0 (on some functions also in D1). After a function call
  39. the registers D0-D1/A0-A1 are destroyed (D0,D1 may contain a returncode) they
  40. are so called scratch registers. All other registers are preserved.
  41. The base of the JMP tower in WHDLoad is similar to a LibraryBase. In
  42. difference to the OS the base must not stand in A6 on calling a function, but
  43. it is recommend to call all functions relative to a address register like
  44.         move.l  (_resload,pc),a5
  45.         jsr     (resload_Decrunch,a5)
  46. The resload base is overgiven in A0 on calling the Slave first via
  47. ws_GameLoader (see chapter WHDLoad.Slave/--Overview--).
  48.  
  49.  
  50. some keywords used in this document:
  51.  
  52.  Slave          the file which contains the interface code
  53.                 (see section WHDLoad.Slave/--Overview--)
  54.  
  55.  BaseMem        the memory which is used by the installed program, because
  56.                 this memory is always Chip-memory and starts at address
  57.                 $00000000, BaseMem is at the same time the size and the end
  58.                 address of the used Chip-memory BaseMem is specified in the
  59.                 Slave-structure in field "ws_BaseMemSize"
  60.  
  61.  ExpMem         is the expansions memory, a extra memory area which can
  62.                 optionally requested by the Slave-structure, it may be
  63.                 Chip- or Fast-memory dependedly on what is available
  64.                 ExpMem is supported starting WHDLoad version 8
  65.  
  66.  DiskImage      a floppy disk stored as a file on hard disk
  67.  
  68. logical values used for returncodes (see dos/dos.i):
  69.  TRUE = -1 (or better <>0)
  70.  FALSE = 0
  71.  
  72. WHDLoad/resload_Abort
  73.  
  74.    NAME
  75.         resload_Abort -- quit and return to operating system
  76.  
  77.    SYNOPSIS
  78.         resload_Abort( success, primary, secondary)
  79.                          (a7)    (4,a7)    (8,a7)
  80.                         ULONG    ULONG     ULONG
  81.  
  82.    FUNCTION
  83.         aborts and terminates the installed program and cause WHDLoad to
  84.         return to the operating system
  85.  
  86.    INPUTS
  87.         success -   the reason for aborting
  88.                     one of TDREASON_#? defined in the include file "whdload.i"
  89.                     depending on this value WHDLoad continues different
  90.                 TDREASON_OK
  91.                     a normal exit will performed
  92.                 TDREASON_DEBUG
  93.                     WHDLoad will create dump files (.whdl_dump, .whdl_memory,
  94.                     .whdl_register) and exit
  95.                 TDREASON_#? (except the above)
  96.                     WHDLoad will show an requester which displays the reason
  97.                     of aborting and requests the user to choose between
  98.                     "Quit", "Restart" and "Make CoreDump"
  99.         primary -   the primary return code further describing the reason of
  100.                     aborting
  101.                 TDREASON_DOSREAD, TDREASON_DOSWRITE, TDREASON_DOSLIST,
  102.                 TDREASON_DISKLOAD, TDREASON_DISKLOADDEV, TDREASON_DELETEFILE
  103.                     dos or trackdisk errorcode
  104.                 TDREASON_DEBUG
  105.                     program counter (so it can by written to the dump files)
  106.                 TDREASON_OSEMUFAIL
  107.                     name of the filed subsystem
  108.                 TDREASON_OK, TDREASON_WRONGVER, TDREASON_REQ68020,
  109.                 TDREASON_REQAGA, TDREASON_MUSTNTSC, TDREASON_MUSTPAL,
  110.                 TDREASON_MUSTREG
  111.                     unused (can be omitted)
  112.         secondary - the secondary return code further describing the reason of
  113.                     aborting
  114.                 TDREASON_DOSREAD, TDREASON_DOSWRITE, TDREASON_DELETEFILE
  115.                     filename
  116.                 TDREASON_DISKLOAD
  117.                     disk number
  118.                 TDREASON_DOSLIST
  119.                     name of directory scanned
  120.                 TDREASON_DEBUG
  121.                     status register (so it can by written to the dump files)
  122.                 TDREASON_OSEMUFAIL
  123.                     error number, depending on the primary return code
  124.                 TDREASON_OK, TDREASON_DISKLOADDEV, TDREASON_WRONGVER,
  125.                 TDREASON_REQ68020, TDREASON_REQAGA, TDREASON_MUSTNTSC,
  126.                 TDREASON_MUSTPAL, TDREASON_MUSTREG
  127.                     unused (can be omitted)
  128.  
  129.    EXAMPLE
  130.         to simply quit:
  131.                 ;primary and secondary wont be needed
  132.                 move.l  #TDREASON_OK,-(a7)
  133.                 move.l  (_resload,pc),a0
  134.                 jmp     (resload_Abort,a0)
  135.         to quit because reading of a file has failed:
  136.                 move.l  a0,-(a7)                        ;a0 = filename
  137.                 move.l  d0,-(a7)                        ;d0 = doserror code
  138.                 move.l  #TDREASON_DOSREAD,-(a7)
  139.                 move.l  (_resload,pc),-(a7)
  140.                 add.l   #resload_Abort,(a7)
  141.                 rts
  142.  
  143.    RESULT
  144.         nothing because WHDLoad will never return from this call
  145.  
  146.    BUGS
  147.  
  148.    NOTE
  149.         this routine is the only one which must be called via JMP and not JSR
  150.         because the parameters are located on the stack (this has the
  151.         advantage that if aborting because TDREASON_DEBUG all registers can be
  152.         preserved and written to the dump files by WHDLoad for further
  153.         diagnostics)
  154.  
  155.    SEE ALSO
  156.         example Slave sources provided with the WHDLoad developer package
  157.  
  158. WHDLoad/resload_Control
  159.  
  160.    NAME
  161.         resload_Control
  162.  
  163.    SYNOPSIS
  164.         success = resload_Control(tags)
  165.           D0                       A0
  166.          BOOL                    STRUCT
  167.  
  168.    FUNCTION
  169.         control function of WHDLoad, allows to get and set various variables
  170.         concerning the software and hardware configuration and to control the
  171.         behavior of some WHDLoad operations
  172.  
  173.    INPUTS
  174.         tags - pointer to a table of tagitems
  175.  
  176.         the following items are currently supported:
  177.  
  178.         WHDLTAG_ATTNFLAGS_GET   - gets the AttnFlags describing the current
  179.                                   CPU, FPU and MMU, the returned value is
  180.                                   similar to execbase.AttnFlags but not equal
  181.                                   because WHDLoad uses some additional bits,
  182.                                   the Slave is only allowed to the use the
  183.                                   defines from the standard include file
  184.                                   "exec/execbase.i" for testing the returned
  185.                                   value
  186.         WHDLTAG_ECLOCKFREQ_GET  - gets the EClockFrequency, which is the
  187.                                   frequency the custom chips operate on, the
  188.                                   value is taken from the execbase (see
  189.                                   standard include file "exec/execbase.i")
  190.         WHDLTAG_MONITOR_GET     - gets the used monitor/video mode, the
  191.                                   returned value is one of NTSC_MONITOR_ID and
  192.                                   PAL_MONITOR_ID (defined in the standard
  193.                                   include file "graphics/modeid.i"), the
  194.                                   WHDLoad options PAL/S and NTSC/S are
  195.                                   affecting the monitor/video mode
  196.         WHDLTAG_BUTTONWAIT_GET  - returns -1 if WHDLoad option ButtonWait/S
  197.                                   has been enabled, otherwise returns 0
  198.         WHDLTAG_CUSTOM1_GET
  199.         WHDLTAG_CUSTOM2_GET
  200.         WHDLTAG_CUSTOM3_GET
  201.         WHDLTAG_CUSTOM4_GET
  202.         WHDLTAG_CUSTOM5_GET     - returns numerical value of WHDLoad option
  203.                                   Custom1/N .. Custom5/N
  204.         WHDLTAG_CBSWITCH_SET    - sets a function which will be executed when
  205.                                   WHDLoad switches from the operating system
  206.                                   to the installed program (see section
  207.                                   WHDLoad/WHDLTAG_CBSWITCH_SET for further
  208.                                   informations)
  209.         WHDLTAG_CHIPREVBITS_GET - gets the ChipRevBits describing the current
  210.                                   custom chips, see standard include file
  211.                                   "graphics/gfxbase.i" for further explanation
  212.         WHDLTAG_IOERR_GET       - gets the dos errorcode of the previously
  213.                                   executed resload function
  214.         WHDLTAG_CBAF_SET        - sets a function which will be executed when
  215.                                   an access fault exception occurs (see
  216.                                   section WHDLoad/WHDLTAG_CBAF_SET for further
  217.                                   informations)
  218.         WHDLTAG_VERSION_GET     - gets WHDLoad major version number
  219.         WHDLTAG_REVISION_GET    - gets WHDLoad minor version number
  220.         WHDLTAG_BUILD_GET       - gets WHDLoad build number
  221.         WHDLTAG_TIME_GET        - gets current time and date, returned will be
  222.                                   a pointer to a filled whdload_time structure
  223.                                   which is decribed in the include file
  224.                                   "whdload.i"
  225.  
  226.    EXAMPLE
  227.         check if current CPU is at least an MC68020:
  228.                 ...
  229.                 clr.l   -(a7)                           ;TAG_DONE
  230.                 clr.l   -(a7)                           ;data to fill
  231.                 move.l  #WHDLTAG_ATTNFLAGS_GET,-(a7)
  232.                 move.l  a7,a0
  233.                 move.l  (_resload,pc),a2
  234.                 jsr     (resload_Control,a2)
  235.                 move.w  (6,a7),d0                       ;D0 = AttnFlags
  236.                 lea     (12,a7),a7                      ;restore sp
  237.                 btst    #AFB_68020,d0
  238.                 beq     .no68020
  239.                 ...
  240.         get video mode and CPU:
  241.                 ...
  242.                 lea     (_tags,pc),a0
  243.                 move.l  (_resload,pc),a2
  244.                 jsr     (resload_Control,a2)
  245.                 move.l  (_mon,pc),d0                    ;D0 = video mode
  246.                 cmp.l   #NTSC_MONITOR_ID,d0
  247.                 beq     .ntsc
  248.                 ...
  249.  
  250.         _tags   dc.l    WHDLTAG_MONITOR_GET
  251.         _mon    dc.l    0
  252.                 dc.l    WHDLTAG_ATTNFLAGS_GET
  253.                 dc.w    0                               ;padding
  254.         _attn   dc.w    0
  255.                 dc.l    0                               ;TAG_DONE
  256.  
  257.    RESULT
  258.         success is true if all items in the taglist has been successfully
  259.         processed
  260.  
  261.    BUGS
  262.  
  263.    NOTE
  264.         requires ws_Version >= 5
  265.  
  266.    SEE ALSO
  267.  
  268. WHDLoad/WHDLTAG_CBAF_SET
  269.  
  270.    NAME
  271.         WHDLTAG_CBAF_SET
  272.  
  273.    SYNOPSIS
  274.         to be used with resload_Control
  275.  
  276.         cont, adr,  data = CBAF(mode, size,  pc,  adr,  data)
  277.          D0    A1    A2          D0    D1    A0    A1    A2
  278.         LONG  APTR  APTR        LONG  LONG  APTR  APTR  APTR
  279.  
  280.    FUNCTION
  281.         using this tag a function can be set which will executed when an
  282.         access fault exception occurs which is not handled by WHDLoad itself,
  283.         it may be used to locate specific accesses in conjunction with
  284.         resload_Protect and to walk around invalid accesses during the
  285.         development process
  286.         using this tag all access faults can be catched except:
  287.          - instruction stream faults
  288.          - faults caused by WHDLoad's blitwait and blitsize checks
  289.         the routine set using this tag must not change any registers except
  290.         the ones holding a return value, the routine must return via RTS, on
  291.         entering the routine all interrupts are disabled (sr=$27xx)
  292.  
  293.    INPUTS
  294.         mode - transfer mode of the faulted access
  295.                 0 - read
  296.                 1 - modify (only 68040/060)
  297.                 2 - write
  298.         size - operand size of the attempted access
  299.                 1 - Byte
  300.                 2 - Word
  301.                 4 - LongWord
  302.         pc   - program counter of the instruction which has faulted
  303.                (warning this may sometimes already the instruction after the
  304.                one which has faulted, read the appropriate microprocessor user
  305.                manual for further informations)
  306.         adr  - the address which has been attempted to access
  307.         data - valid only on write operations, the given memory address
  308.                contains the data which has been tried to write
  309.  
  310.    RESULT
  311.         cont - how to continue
  312.                 0 - terminate, WHDLoad will show a requester notifying the
  313.                     access fault
  314.                 1 - proceed, the faulted access will be emulated by the
  315.                     handler inside great WHDLoad
  316.         adr  - in case of cont=proceed the address which will be accessed
  317.         data - in case of cont=proceed and mode=write a pointer to the data
  318.                which will be written (only 68030)
  319.  
  320.    EXAMPLE
  321.         if you want to get informed at which point the installed program
  322.         writes the value 42 to the address $BABE, use the following code:
  323.                 ...
  324.                 clr.l   -(a7)                           ;TAG_DONE
  325.                 pea     (_af,pc)                        ;function
  326.                 move.l  #WHDLTAG_CBAF_SET,-(a7)
  327.                 move.l  a7,a0
  328.                 move.l  (_resload,pc),a2
  329.                 jsr     (resload_Control,a2)
  330.                 lea     (12,a7),a7                      ;restore sp
  331.                 moveq   #2,d0
  332.                 lea     ($BABE),a0
  333.                 jsr     (resload_ProtectWrite,a2)       ;protect area
  334.                 ...
  335.  
  336.      _af        cmp.l   #$BABE,a1                       ;correct address ?
  337.                 bne     .term
  338.                 cmp.w   #2,d1                           ;size
  339.                 bne     .term
  340.                 cmp.w   #42,(a2)
  341.                 beq     .term
  342.                 moveq   #1,d0                           ;proceed
  343.                 rts
  344.  
  345.     .term       moveq   #0,d0                           ;terminate
  346.                 rts
  347.  
  348.    EXAMPLE
  349.         if want you to redirect an access to $24 to the address $300, use the
  350.         following code:
  351.                 ...
  352.                 clr.l   -(a7)                           ;TAG_DONE
  353.                 pea     (_af,pc)                        ;function
  354.                 move.l  #WHDLTAG_CBAF_SET,-(a7)
  355.                 move.l  a7,a0
  356.                 move.l  (_resload,pc),a2
  357.                 jsr     (resload_Control,a2)
  358.                 lea     (12,a7),a7                      ;restore sp
  359.                 moveq   #4,d0
  360.                 lea     ($24),a0
  361.                 jsr     (resload_ProtectWrite,a2)       ;protect area
  362.                 ...
  363.  
  364.      _af        cmp.l   #$24,a1                         ;correct address ?
  365.                 bne     .term
  366.                 lea     ($300),a1
  367.                 moveq   #1,d0                           ;proceed
  368.                 rts
  369.  
  370.     .term       moveq   #0,d0                           ;terminate
  371.                 rts
  372.  
  373.  
  374.    BUGS
  375.         currently only 68030 is supported
  376.  
  377.    NOTE
  378.         requires ws_Version >= 9
  379.         MUST not be used in public releases, use for development process only
  380.  
  381.    SEE ALSO
  382.         resload_Control
  383.  
  384. WHDLoad/WHDLTAG_CBSWITCH_SET
  385.  
  386.    NAME
  387.         WHDLTAG_CBSWITCH_SET
  388.  
  389.    SYNOPSIS
  390.         to be used with resload_Control
  391.  
  392.         CBSWITCH()
  393.  
  394.    FUNCTION
  395.         using this tag a routine can be set which will executed each time
  396.         WHDLoad switches from the operating system to the installed program
  397.         such a routine is sometimes necessary because during the switch
  398.         between the installed program and the operating system some hardware
  399.         registers are modified by the operating system
  400.         known registers to be modified are cop2lc, bltafwm and bltalwm, maybe
  401.         there are more of them
  402.         the routine must not change any registers, must not use any stack and
  403.         has to return via "jmp (a0)", at execution time of the routine all
  404.         interrupts and dma's are disabled and the memory setup of the
  405.         installed program is active
  406.  
  407.    INPUTS
  408.         pointer to the routine to execute during switch, a value equal 0
  409.         disables the execution of a routine
  410.  
  411.    EXAMPLE
  412.                 ...
  413.                 clr.l   -(a7)                           ;TAG_DONE
  414.                 pea     (_cbswitch,pc)                  ;function
  415.                 move.l  #WHDLTAG_CBSWITCH_SET,-(a7)
  416.                 move.l  a7,a0
  417.                 move.l  (_resload,pc),a2
  418.                 jsr     (resload_Control,a2)
  419.                 lea     (12,a7),a7                      ;restore sp
  420.                 ...
  421.  
  422.      _cbswitch  move.l  (_c2,pc),(_custom+cop2lc)
  423.                 jmp     (a0)
  424.  
  425.      _cb2       dc.l    $10e80
  426.  
  427.    RESULT
  428.         none
  429.  
  430.    BUGS
  431.  
  432.    NOTE
  433.         requires ws_Version >= 7
  434.  
  435.    SEE ALSO
  436.         resload_Control
  437.  
  438. WHDLoad/WHDLTAG_IOERR_GET
  439.  
  440.    NAME
  441.         WHDLTAG_IOERR_GET
  442.  
  443.    SYNOPSIS
  444.         to be used with resload_Control
  445.  
  446.    FUNCTION
  447.         this tag can be used to get the dos errorcode of the last called
  448.         resload function, all resload functions except resload_Control will
  449.         set/reset this error code
  450.         two resload functions are special in that way:
  451.             resload_GetFileSize
  452.                 if a file with the specified name cannot be opened via
  453.                 dos.Open, the error code will be set to the value returned
  454.                 from dos.IoErr, so the error code may contain values like
  455.                 ERROR_OBJECT_NOT_FOUND, ERROR_OBJECT_WRONG_TYPE,
  456.                 ERROR_READ_PROTECTED or similar stuff from dos/dos.i
  457.                 the errorcode can be used to distinguish between a file with
  458.                 size of 0 and a nonexistent file
  459.             resload_ListFiles
  460.                 if the specified buffer to fill is not large enough to hold
  461.                 all filenames from the scanned directory, the error code will
  462.                 be set to ERROR_NO_FREE_STORE
  463.  
  464.    INPUTS
  465.         none
  466.  
  467.    EXAMPLE
  468.                 ...
  469.                 clr.l   -(a7)                           ;TAG_DONE
  470.                 clr.l   -(a7)                           ;data to fill
  471.                 move.l  #WHDLTAG_IOERR_GET,-(a7)
  472.                 move.l  a7,a0
  473.                 move.l  (_resload,pc),a2
  474.                 jsr     (resload_Control,a2)
  475.                 move.l  (4,a7),d0                       ;D0 = IoErr
  476.                 lea     (12,a7),a7                      ;restore sp
  477.                 ...
  478.  
  479.    RESULT
  480.         none
  481.  
  482.    BUGS
  483.  
  484.    NOTE
  485.         requires ws_Version >= 8
  486.  
  487.    SEE ALSO
  488.         resload_Control, resload_GetFileSize, resload_ListFiles
  489.  
  490. WHDLoad/resload_CRC16
  491.  
  492.    NAME
  493.         resload_CRC16 -- calculate ANSI conform 16 bit CRC checksum
  494.  
  495.    SYNOPSIS
  496.         checksum = resload_CRC16(length,address)
  497.            D0                      D0     A0
  498.          UWORD                   ULONG   APTR
  499.  
  500.    FUNCTION
  501.         calculate ANSI conform 16 bit CRC checksum
  502.         mostly used to difference between various program versions
  503.  
  504.    INPUTS
  505.         length  - length of area to calculate over
  506.         address - pointer to area
  507.  
  508.    EXAMPLE
  509.                 ...
  510.                 lea     $1000,a0                ;at address $1000
  511.                 move.l  #256,d0                 ;upto address $1100
  512.                 move.l  (_resload,pc),a2
  513.                 jsr     (resload_CRC16,a2)
  514.                 cmp.w   #$f2b7,d0
  515.                 bne     .false_version
  516.                 ...
  517.  
  518.    RESULT
  519.         checksum - 16 bit crc
  520.  
  521.    BUGS
  522.  
  523.    NOTE
  524.         requires ws_Version >= 3
  525.  
  526.    SEE ALSO
  527.  
  528. WHDLoad/resload_Decrunch
  529.  
  530.    NAME
  531.         resload_Decrunch -- uncompress data in memory
  532.  
  533.    SYNOPSIS
  534.         size = resload_Decrunch(source, destination)
  535.          D0                       A0        A1
  536.         ULONG                    APTR      APTR
  537.  
  538.    FUNCTION
  539.         unpack compressed data in memory, known compressed data formats are
  540.         RNC1, RNC2, IMP! and ATN!
  541.         the function first checks if the data source points to is a known
  542.         compressed format, if not it returns with size=0, else the data will
  543.         be unpacked to the destination and the size of the decompressed data
  544.         is returned
  545.         source and destination can be equal, in that case the packed data will
  546.         be overwritten
  547.  
  548.         RNC1:   rob northen compressor - emphasis on packed size, supported is
  549.                 the old and the new format, both formats using the same id but
  550.                 different file formats and compressing algorithms, the
  551.                 function uses some heuristic checks to determinate the correct
  552.                 format, the decompressor for the new common format is highly
  553.                 optimized and contains a routine for 68000/010 and one for
  554.                 68020+, on 68060 it is faster than the IMP! decompressor!
  555.         RNC2:   rob northen compressor - emphasis on unpacking speed, the
  556.                 fastest supported decompressor
  557.         IMP!:   imploder (FImp), the packed data data must not overlap the
  558.                 destinaion for unpacking but the destination must be equal the
  559.                 source or outside the source data, in difference to the
  560.                 original explode routine resload_Decrunch does not destroy the
  561.                 source data (if source is not equal destination)
  562.         ATN!:   identical to IMP! only id is different
  563.  
  564.         all decompressing routines has been modified to not modify the
  565.         registers A5 and A6 and to use nearly no stack space
  566.         all decompressing routines performing a check if the decompression was
  567.         successful, on a failure the installed program will be terminated and
  568.         WHDLoad will display a message concerning this
  569.  
  570.  
  571.    INPUTS
  572.         source      - address of source in memory
  573.         destination - address of destination in memory (can be equal to source)
  574.  
  575.    EXAMPLE
  576.  
  577.    RESULT
  578.         size - the size of the uncompressed data or 0 if is not compressed
  579.                with a known format
  580.  
  581.    BUGS
  582.  
  583.    NOTE
  584.         the routine performs automatically a resload_FlushCache before
  585.         returning
  586.  
  587.    SEE ALSO
  588.         resload_LoadFileDecrunch
  589.  
  590. WHDLoad/resload_Delay
  591.  
  592.    NAME
  593.         resload_Delay -- wait some time
  594.  
  595.    SYNOPSIS
  596.         resload_Delay(time)
  597.                        D0
  598.                       ULONG
  599.  
  600.    FUNCTION
  601.         wait the specified time or until a button is pressed, all possible
  602.         buttons (LMB, MMB, RMB) of both controllers (port 0/1) are checked,
  603.         after the time runs out or a button is pressed the function waits
  604.         until all buttons has been released
  605.         the wait routine is based on the raster beam, but checks the current
  606.         display and therefore waits the correct time on PAL and NTSC
  607.  
  608.    INPUTS
  609.         time - time to wait in 1/10 seconds
  610.  
  611.    EXAMPLE
  612.                 ...
  613.                 moveq   #30,d0                  ;3 seconds
  614.                 move.l  (_resload,pc),a2
  615.                 jsr     (resload_Delay,a2)
  616.                 ...
  617.  
  618.    RESULT
  619.         nothing, all registers are preserved
  620.  
  621.    BUGS
  622.  
  623.    NOTE
  624.         in difference to most others resload_#? function this routine is
  625.         granted to preserve all registers
  626.         requires ws_Version >= 8
  627.  
  628.    SEE ALSO
  629.  
  630. WHDLoad/resload_DeleteFile
  631.  
  632.    NAME
  633.         resload_Delete -- delete file
  634.  
  635.    SYNOPSIS
  636.         success,errorcode = resload_DeleteFile(name)
  637.           D0       D1                           A0
  638.          BOOL    ULONG                         CPTR
  639.  
  640.    FUNCTION
  641.         deletes the file or directory with the specified name
  642.  
  643.    INPUTS
  644.         name - name of the file/directory to delete
  645.  
  646.    EXAMPLE
  647.                 ...
  648.                 lea     (_name,pc),a0
  649.                 move.l  (_resload,pc),a2
  650.                 jsr     (resload_DeleteFile,a2)
  651.                 ...
  652.  
  653.         _name   dc.b    "C:WHDLoad",0
  654.  
  655.    RESULT
  656.         success   - TRUE on success
  657.         errorcode - 0 on success
  658.                     otherwise a dos-errorcode from dos.IoErr()
  659.         if WHDLF_NoError is set, the function only returns on success
  660.  
  661.    BUGS
  662.  
  663.    NOTE
  664.         requires ws_Version >= 8
  665.  
  666.    SEE ALSO
  667.  
  668. WHDLoad/resload_DiskLoad
  669.  
  670.    NAME
  671.         resload_DiskLoad -- load part from a diskimage
  672.  
  673.    SYNOPSIS
  674.         success,errorcode = resload_DiskLoad(offset,size,diskno,dest)
  675.           D0       D1                          D0    D1    D2    A0
  676.          BOOL    ULONG                        ULONG ULONG UBYTE APTR
  677.  
  678.    FUNCTION
  679.         load part from a diskimage
  680.  
  681.    INPUTS
  682.         offset - offset in diskimage (relative to the beginning)
  683.         size   - amount of bytes to read
  684.         diskno - disk number
  685.         dest   - destination address
  686.  
  687.    EXAMPLE
  688.                 ...
  689.                 move.l  #880*512,d0             ;from block 880
  690.                 move.l  #2*512,d1               ;2 blocks
  691.                 moveq   #1,d2                   ;disk 1
  692.                 lea     $80000,a0               ;destination
  693.                 move.l  (_resload,pc),a2
  694.                 jsr     (resload_LoadDisk,a2)
  695.                 ...
  696.  
  697.    RESULT
  698.         success   - TRUE on success
  699.         errorcode - 0 on success
  700.                     otherwise a dos-errorcode from dos.IoErr()
  701.         if WHDLF_NoError is set, the function only returns on success
  702.  
  703.    BUGS
  704.  
  705.    NOTE
  706.         the name of the disk images must be "disk." followed by the disk
  707.         number (i.e. "Disk.1")
  708.         the size of the diskimages is variable, an attempt to read data
  709.         outside the disk image will result in a seek error
  710.         the routine performs automatically a resload_FlushCache before
  711.         returning
  712.  
  713.    SEE ALSO
  714.         resload_LoadFileOffset
  715.  
  716. WHDLoad/resload_DiskLoadDev
  717.  
  718.    NAME
  719.         resload_DiskLoadDev -- load part from a floppy disk
  720.  
  721.    SYNOPSIS
  722.         success,errorcode = resload_DiskLoadDev(offset, size,  dest,  tags)
  723.           D0       D1                             D0     D1     A0     A1
  724.          BOOL    ULONG                          ULONG  ULONG  UBYTE  STRUCT
  725.  
  726.    FUNCTION
  727.         load a given amount of bytes from a floppy like device
  728.  
  729.    INPUTS
  730.         offset - offset on the disk (relative to the beginning)
  731.         size   - amount of bytes to read (at the moment this must be a
  732.                  multiple of 512 bytes)
  733.         dest   - destination address (at the moment this must be aligned
  734.                  to 512 bytes)
  735.         tags   - pointer to a taglist (at the moment there are no valid
  736.                  tags, so this must be NULL)
  737.  
  738.    EXAMPLE
  739.                 ...
  740.                 move.l  #880*512,d0             ;from block 880
  741.                 move.l  #2*512,d1               ;2 blocks
  742.                 lea     $80000,a0               ;destination
  743.                 sub.l   a1,a1                   ;tag list
  744.                 move.l  (_resload,pc),a2
  745.                 jsr     (resload_LoadDisk,a2)
  746.                 ...
  747.  
  748.    RESULT
  749.         success   - TRUE on success
  750.         errorcode - 0 on success
  751.                     otherwise a trackdisk errorcode
  752.         if WHDLF_NoError is set, the function only returns on success
  753.  
  754.    BUGS
  755.  
  756.    NOTE
  757.         requires ws_Version >= 2
  758.         at the moment all (size, address) must be aligned to 512 bytes due
  759.         restrictions of trackdisk.device
  760.         the routine performs automatically a resload_FlushCache before
  761.         returning
  762.  
  763.    SEE ALSO
  764.  
  765. WHDLoad/resload_FlushCache
  766.  
  767.    NAME
  768.         resload_FluchCache -- clear CPU caches
  769.  
  770.    SYNOPSIS
  771.         resload_FlushCache()
  772.  
  773.    FUNCTION
  774.         clear all CPU caches
  775.  
  776.    INPUTS
  777.  
  778.    EXAMPLE
  779.  
  780.    RESULT
  781.  
  782.    BUGS
  783.  
  784.    NOTE
  785.         in difference to most others resload_#? function this routine is
  786.         granted to preserve all registers
  787.         it is safe to call this routine from User or Supervisor mode and
  788.         independend from the actual CPU type (also on 68000/010)
  789.         it uses the CACR on 68020/030 and a "cpusha bc" on 68040/060
  790.  
  791.    SEE ALSO
  792.         resload_SetCPU
  793.  
  794. WHDLoad/resload_GetFileSize
  795.  
  796.    NAME
  797.         resload_GetFileSize -- get size of a file
  798.  
  799.    SYNOPSIS
  800.         size = resload_GetFileSize(name)
  801.          D0                         A0
  802.         ULONG                      CPTR
  803.  
  804.    FUNCTION
  805.         get size of a file, or check if a file exists
  806.         to distinguish between a file with a size of 0 and an nonexisting
  807.         file the tag WHDLTAG_IOERR_GET must be used in conjunction with
  808.         resload_Control
  809.  
  810.    INPUTS
  811.         name - name of the file to get size from
  812.  
  813.    EXAMPLE
  814.                 ...
  815.                 lea     (_filename,pc),a0
  816.                 move.l  (_resload,pc),a2
  817.                 jsr     (resload_GetFileSize,a2)
  818.                 tst.l   d0
  819.                 bne     .file_not_exist
  820.                 ...
  821.  
  822.    RESULT
  823.         size - the size of the file, 0 if does not exist
  824.  
  825.    BUGS
  826.  
  827.    NOTE
  828.         this routine returns the filesize obtained by the filesystem, if the
  829.         file is compressed and is loaded later via resload_LoadFileDecrunch
  830.         the loaded filesize will differ!
  831.  
  832.    SEE ALSO
  833.         resload_Control, resload_LoadFile, resload_LoadFileDecrunch
  834.  
  835. WHDLoad/resload_ListFiles
  836.  
  837.    NAME
  838.         resload_ListFiles -- list filenames of a directory
  839.  
  840.    SYNOPSIS
  841.         amount,errorcode = resload_ListFiles(buffersize, name, buffer)
  842.           D0      D1                             D0       A0     A1
  843.         ULONG   ULONG                          ULONG     CPTR   APTR
  844.  
  845.    FUNCTION
  846.         writes the names of all files in the specified directory to the
  847.         buffer, the file names are separated with a $0 character
  848.         only files are listed, directories are skipped
  849.         if the buffer to fill is not large enough to hold all file names the
  850.         routine fills it as far as possible, the tag WHDLTAG_IOERR_GET in
  851.         conjunction with resload_Control can be used to check if all file
  852.         names have fit into the buffer
  853.  
  854.  
  855.    INPUTS
  856.         buffersize - the size of the buffer
  857.         name       - the name of the directory to scan
  858.         buffer     - pointer to the buffer (the buffer must be located inside
  859.                      the Slave)
  860.  
  861.    EXAMPLE
  862.                 ...
  863.                 move.l  #_bufend-_buf,d0
  864.                 lea     (_savepath,pc),a0
  865.                 lea     (_buf,pc),a1
  866.                 move.l  (_resload,pc),a2
  867.                 jsr     (resload_ListFiles,a2)
  868.                 ...
  869.  
  870.         _buf      ds.b    1000
  871.         _bufend
  872.         _savepath dc.b  "/save",0       ;this must be a relative path!
  873.  
  874.  
  875.    RESULT
  876.         amount    - amount of listed files in the buffer
  877.         errorcode - 0 on success
  878.                     otherwise a dos-errorcode from dos.IoErr()
  879.         if WHDLF_NoError is set, the function only returns on success
  880.  
  881.    BUGS
  882.  
  883.    NOTE
  884.  
  885.    SEE ALSO
  886.         resload_Control
  887.  
  888. WHDLoad/resload_LoadFile
  889.  
  890.    NAME
  891.         resload_LoadFile -- load file into memory
  892.  
  893.    SYNOPSIS
  894.         length,errorcode = resload_LoadFile(name, address)
  895.           D0      D1                         A0      A1
  896.         ULONG    ULONG                      CPTR    APTR
  897.  
  898.    FUNCTION
  899.         load file to the specified memory address
  900.  
  901.    INPUTS
  902.         name    - name of the file to load
  903.         address - memory address to load the file on
  904.  
  905.    EXAMPLE
  906.                 ...
  907.                 lea     (_filename),a0          ;name
  908.                 lea     $1000.w,a1              ;destination
  909.                 move.l  (_resload,pc),a2
  910.                 jsr     (resload_LoadFile,a2)
  911.                 ...
  912.  
  913.    RESULT
  914.         length    - the size of the loaded file, or 0 on error
  915.         errorcode - 0 on success
  916.                     otherwise a dos-errorcode from dos.IoErr()
  917.         if WHDLF_NoError is set, the function only returns on success
  918.  
  919.    BUGS
  920.  
  921.    NOTE
  922.         the routine performs automatically a resload_FlushCache before
  923.         returning
  924.  
  925.    SEE ALSO
  926.         resload_LoadFileDecrunch, resload_LoadFileOffset
  927.  
  928. WHDLoad/resload_LoadFileDecrunch
  929.  
  930.    NAME
  931.         resload_LoadFileDecrunch -- load file and uncompress
  932.  
  933.    SYNOPSIS
  934.         length,errorcode = resload_LoadFileDecrunch(name, address)
  935.           D0      D1                                 A0      A1
  936.         ULONG    ULONG                              CPTR    APTR
  937.  
  938.    FUNCTION
  939.         loads the specified file into memory and unpack it if it is in a
  940.         supported compressed data format
  941.         using this routine instead of resload_LoadFile easily allows it to add
  942.         support for compressed data files to a installed program, the
  943.         decompression is absolutely transparent, so the installed program will
  944.         not detect if the files loaded are compressed on disk or not, the only
  945.         thing which must be considered is that files that are written using
  946.         resload_SaveFileOffset or loaded via resload_LoadFileOffset must not
  947.         be compressed
  948.  
  949.    INPUTS
  950.         name    - name of file to load
  951.         address - memory address to load the file on
  952.  
  953.    EXAMPLE
  954.                 ...
  955.                 lea     (_filename),a0          ;name
  956.                 lea     $1000.w,a1              ;destination
  957.                 move.l  (_resload,pc),a2
  958.                 jsr     (resload_LoadFileDecrunch,a2)
  959.                 ...
  960.  
  961.    RESULT
  962.         length    - the size of the loaded file
  963.                     if an error occurs this is 0
  964.         errorcode - 0 on success
  965.                     otherwise a dos-errorcode from dos.IoErr()
  966.         if WHDLF_NoError is set, the function only returns on success
  967.  
  968.    BUGS
  969.  
  970.    NOTE
  971.         the routine performs automatically a resload_FlushCache before
  972.         returning
  973.  
  974.    SEE ALSO
  975.         resload_Decrunch, resload_LoadFile, resload_LoadFileOffset,
  976.         resload_SaveFile, resload_SaveFileOffset
  977.  
  978. WHDLoad/resload_LoadFileOffset
  979.  
  980.    NAME
  981.         resload_LoadFileOffset -- load data inside a file to memory
  982.  
  983.    SYNOPSIS
  984.         success,error = resload_LoadFileOffset(size, offset, name, address)
  985.           D0     D1                             D0     D1     A0      A1
  986.          BOOL   ULONG                          ULONG  ULONG  CPTR    APTR
  987.  
  988.    FUNCTION
  989.         load a part of a file into memory, the part of the file is specified
  990.         by an offset in the file and a byte count to read, the routine is
  991.         nearly identical to resload_DiskLoad but instead of specifying the
  992.         number of the disk to read from a filename is used to select the file
  993.  
  994.    INPUTS
  995.         size    - amount of bytes to read
  996.         offset  - offset in the file
  997.         name    - name of file
  998.         address - memory address to load the file on
  999.  
  1000.    EXAMPLE
  1001.                 ...
  1002.                 move.l  #512,d0                 ;size
  1003.                 move.l  #$4000,d1               ;offset
  1004.                 lea     (_save,pc),a0           ;name
  1005.                 lea     $5ac20,a1               ;source
  1006.                 move.l  (_resload,pc),a2
  1007.                 jsr     (resload_LoadFileOffset,a2)
  1008.                 ...
  1009.  
  1010.         _save   dc.b    "saved",0
  1011.  
  1012.    RESULT
  1013.         success   - TRUE on success
  1014.         errorcode - 0 on success
  1015.                     otherwise a dos-errorcode from dos.IoErr()
  1016.         if WHDLF_NoError is set, the function only returns on success
  1017.  
  1018.    BUGS
  1019.  
  1020.    NOTE
  1021.         the routine performs automatically a resload_FlushCache before
  1022.         returning
  1023.         requires ws_Version >= 6
  1024.  
  1025.    SEE ALSO
  1026.         resload_DiskLoad, resload_LoadFile
  1027.  
  1028. WHDLoad/resload_Patch
  1029.  
  1030.    NAME
  1031.         resload_Patch -- apply patchlist
  1032.  
  1033.    SYNOPSIS
  1034.         resload_Patch(patchlist, destination)
  1035.                          A0          A1
  1036.                         APTR        APTR
  1037.  
  1038.    FUNCTION
  1039.         modify memory using commands from a specified patch list,
  1040.         to make an installed program working under WHDLoad it must be patched,
  1041.         that means the program must be modified so that it will load data via
  1042.         WHDLoad instead of using its own loader routines, often also various
  1043.         other things must be changed to make it working
  1044.         the modifying of the installed program can be done using this routine,
  1045.         a patch list will be build by using macros from the include file
  1046.         "whdpatch.i", each entry in the patchlist specifies a command to
  1047.         perform, an address to apply the command on and optional extra data,
  1048.         resload_Patch is especially useful if the memory to modify is located
  1049.         in the ExpMem and therefore the destination address in only know at
  1050.         runtime and not at creation time of the Slave
  1051.  
  1052.    INPUTS
  1053.         patchlist   - list of commands describing the patches to apply
  1054.         destination - address of memory region to patch
  1055.  
  1056.    EXAMPLE
  1057.                 ...
  1058.                 lea     (_pl,pc),a0             ;patchlist
  1059.                 move.l  (_expmem,pc),a1         ;destination
  1060.                 move.l  (_resload,pc),a2
  1061.                 jsr     (resload_Patch,a2)
  1062.                 ...
  1063.  
  1064.         _pl     PL_START
  1065.                 PL_P    $560,_loadfile          ;the loading routine
  1066.                 PL_R    $2046                   ;copylock
  1067.                 PL_END
  1068.  
  1069.    RESULT
  1070.  
  1071.    BUGS
  1072.  
  1073.    NOTE
  1074.         the routine performs automatically a resload_FlushCache before
  1075.         returning
  1076.         requires ws_Version >= 10
  1077.  
  1078.    SEE ALSO
  1079.  
  1080. WHDLoad/resload_ProtectRead
  1081.  
  1082.    NAME
  1083.         resload_ProtectRead -- mark memory as read protected
  1084.  
  1085.    SYNOPSIS
  1086.         resload_ProtectRead(length, address)
  1087.                               D0      A0
  1088.                              ULONG   APTR
  1089.  
  1090.    FUNCTION
  1091.         protect the specified memory against reading by the processor
  1092.         the memory to protect must be located inside BaseMem or ExpMem
  1093.  
  1094.    INPUTS
  1095.         length  - size of the memory area to protected
  1096.         address - start address of the memory area to protected
  1097.  
  1098.    EXAMPLE
  1099.                 ...
  1100.                 moveq   #4,d0                   ;one longword
  1101.                 lea     $4070,a0                ;address
  1102.                 move.l  (_resload,pc),a2
  1103.                 jsr     (resload_ProtectRead,a2)
  1104.                 ...
  1105.  
  1106.    RESULT
  1107.         a "Exception 'Access Fault'" WHDLoad requester if the protected memory
  1108.         is accessed
  1109.  
  1110.    BUGS
  1111.         the amount of protected areas is currently limited to 16,
  1112.         the page where the SSP points to must not be protected, because if a
  1113.         Access Fault occurs the CPU will be unable in that case to write the
  1114.         exception stackframe, only reset will recover from the resulting
  1115.         Double Bus Fault
  1116.         limitations on MC68020+MC68851:
  1117.           this hardware is currently not supported
  1118.         limitations on MC68030:
  1119.           - 3-byte transfers are not supported (occuring on misaligned
  1120.             longword accesses to page boundaries eg. "tst.l $fff" (assumed
  1121.             4KByte page size))
  1122.           - locked accesses (tas/cas/cas2) are not supported
  1123.         limitations on MC68040:
  1124.           this hardware is currently not supported
  1125.         limitations on MC68060:
  1126.           - misaligned access are not supported (occuring on accesses trough a
  1127.             page boundary, for example "tst.l ($ffe)" (assumed 4KByte page
  1128.             size))
  1129.           - locked accesses (tas/cas) are not supported
  1130.           - instructions which are located on a protected page and access the
  1131.             supervisor portion of the status register will be executed wrong
  1132.             (these instructions will always see the trace bit as 1 and the
  1133.             interrupt level as 7, any modification of the status register
  1134.             supervisor portion will be without effect)
  1135.           - movem instruction may access a protected area without creating a
  1136.             Access Fault exception (only the first bus cycle of the excution
  1137.             unit will be verified for matching a protected area)
  1138.           - move16 and double precision operations (FPU) are unsupported
  1139.           - a "move (mem),(mem)" with overlapping source and destination
  1140.             address which generates an Access Fault because Misalignment
  1141.             will be executed wrong, for example "move.l ($ffc),($ffe)" where
  1142.             page $1000..$1fff is protected and memory before execution
  1143.             contains ($ffc)=$11112222,($1000)=$33334444, after execution
  1144.             $1000 contains $11114444 and not $22224444)
  1145.         unsupported accesses will result in a "Exception 'Access Fault'"
  1146.         WHDLoad requester
  1147.  
  1148.    NOTE
  1149.         requires ws_Version >= 6
  1150.         the MMU must be in use by WHDLoad, otherwise you will get WHDLoad
  1151.         requester "Unacceptible Arguments".
  1152.         only accesses to the user and supervisor data stream are affected
  1153.         (this means not affected are: CPU space accesses (eg getting values
  1154.         from the vector table) and instruction stream accesses)
  1155.  
  1156.    SEE ALSO
  1157.         resload_ProtectReadWrite, resload_ProtectWrite, resload_ProtectRemove
  1158.  
  1159. WHDLoad/resload_ProtectReadWrite
  1160.  
  1161.    NAME
  1162.         resload_ProtectReadWrite -- mark memory as read and write protected
  1163.  
  1164.    SYNOPSIS
  1165.         resload_ProtectReadWrite(length, address)
  1166.                                    D0      A0
  1167.                                   ULONG   APTR
  1168.  
  1169.    FUNCTION
  1170.         protect the specified memory against reading and writing by the
  1171.         processor
  1172.         the memory to protect must be located inside BaseMem or ExpMem
  1173.  
  1174.    INPUTS
  1175.         length  - size of the memory area to protected
  1176.         address - start address of the memory area to protected
  1177.  
  1178.    EXAMPLE
  1179.                 ...
  1180.                 moveq   #4,d0                   ;one longword
  1181.                 lea     $64,a0                  ;address
  1182.                 move.l  (_resload,pc),a2
  1183.                 jsr     (resload_ProtectReadWrite,a2)
  1184.                 ...
  1185.  
  1186.    RESULT
  1187.         a "Exception 'Access Fault'" WHDLoad requester if the protected memory
  1188.         is accessed
  1189.  
  1190.    BUGS
  1191.         the amount of protected areas is currently limited to 16,
  1192.         the page where the SSP points to must not be protected, because if a
  1193.         Access Fault occurs the CPU will be unable in that case to write the
  1194.         exception stackframe, only reset will recover from the resulting
  1195.         Double Bus Fault
  1196.         limitations on MC68020+MC68851:
  1197.           this hardware is currently not supported
  1198.         limitations on MC68030:
  1199.           - 3-byte transfers are not supported (occuring on misaligned
  1200.             longword accesses to page boundaries eg. "tst.l $fff" (assumed
  1201.             4KByte page size))
  1202.           - locked accesses (tas/cas/cas2) are not supported
  1203.         limitations on MC68040:
  1204.           this hardware is currently not supported
  1205.         limitations on MC68060:
  1206.           - misaligned access are not supported (occuring on accesses trough a
  1207.             page boundary, for example "tst.l ($ffe)" (assumed 4KByte page
  1208.             size))
  1209.           - locked accesses (tas/cas) are not supported
  1210.           - instructions which are located on a protected page and access the
  1211.             supervisor portion of the status register will be executed wrong
  1212.             (these instructions will always see the trace bit as 1 and the
  1213.             interrupt level as 7, any modification of the status register
  1214.             supervisor portion will be without effect)
  1215.           - movem instruction may access a protected area without creating a
  1216.             Access Fault exception (only the first bus cycle of the excution
  1217.             unit will be verified for matching a protected area)
  1218.           - move16 and double precision operations (FPU) are unsupported
  1219.           - a "move (mem),(mem)" with overlapping source and destination
  1220.             address which generates an Access Fault because Misalignment
  1221.             will be executed wrong, for example "move.l ($ffc),($ffe)" where
  1222.             page $1000..$1fff is protected and memory before execution
  1223.             contains ($ffc)=$11112222,($1000)=$33334444, after execution
  1224.             $1000 contains $11114444 and not $22224444)
  1225.         unsupported accesses will result in a "Exception 'Access Fault'"
  1226.         WHDLoad requester
  1227.  
  1228.    NOTE
  1229.         requires ws_Version >= 6
  1230.         the MMU must be in use by WHDLoad, otherwise you will get WHDLoad
  1231.         requester "Unacceptible Arguments".
  1232.         only accesses to the user and supervisor data stream are affected
  1233.         (this means not affected are: CPU space accesses (eg getting values
  1234.         from the vector table) and instruction stream accesses)
  1235.  
  1236.    SEE ALSO
  1237.         resload_ProtectRead, resload_ProtectWrite, resload_ProtectRemove
  1238.  
  1239. WHDLoad/resload_ProtectRemove
  1240.  
  1241.    NAME
  1242.         resload_ProtectRemove -- remove protection from memory area
  1243.  
  1244.    SYNOPSIS
  1245.         resload_ProtectRemove(length, address)
  1246.                                 D0      A0
  1247.                                ULONG   APTR
  1248.  
  1249.    FUNCTION
  1250.         remove a previously created protection
  1251.         the specified area must exactly match the previously protected area
  1252.  
  1253.    INPUTS
  1254.         length  - size of the memory area to protected
  1255.         address - start address of the memory area to protected
  1256.  
  1257.    EXAMPLE
  1258.                 ...
  1259.                 moveq   #4,d0                   ;one longword
  1260.                 lea     $64,a0                  ;address
  1261.                 move.l  (_resload,pc),a2
  1262.                 jsr     (resload_ProtectRemove,a2)
  1263.                 ...
  1264.  
  1265.    RESULT
  1266.  
  1267.    BUGS
  1268.  
  1269.    NOTE
  1270.         requires ws_Version >= 6
  1271.  
  1272.    SEE ALSO
  1273.         resload_ProtectRead, resload_ProtectWrite, resload_ProtectWrite
  1274.  
  1275. WHDLoad/resload_ProtectSMC
  1276.  
  1277.    NAME
  1278.         resload_ProtectSMC -- detect self modifying code
  1279.  
  1280.    SYNOPSIS
  1281.         resload_ProtectSMC(length, address)
  1282.                              D0      A0
  1283.                             ULONG   APTR
  1284.  
  1285.    FUNCTION
  1286.         Enables automatically detection of self modifying code (SMC) in the
  1287.         selected area. The selected area will be write protected using the
  1288.         resload_ProtectWrite mechanism, additional the trace mode will be
  1289.         activated and a special handler for trace exceptions installed.
  1290.         Each write access to the selected area will be logged to a private
  1291.         memory location. On each instruction executed inside the selected
  1292.         memory the trace handler verifies, if the instruction has been
  1293.         previosly modified. If an executed instruction has been altered
  1294.         the installed program will be terminated and WHDLoad will show an
  1295.         requester informing about the SMC-detection.
  1296.         To determinate the size of instructions a table is used. This table
  1297.         contains the opcode size in words depending on the first instruction
  1298.         word. If the trace exception handler encounters a instruction with
  1299.         unknown size WHDLoad aborts with an "Internal Error #3". The reason
  1300.         for this maybe an illegal instruction, an instruction available only
  1301.         in higher processors than 68000 or an incompleteness of the internal
  1302.         instruction size table (IST). To aid this, during the initialisation
  1303.         of this function WHDLoad searches first for an external IST. This
  1304.         must be located in the same directory where the WHDLoad executable
  1305.         resides and is searched as "PROGDIR:WHDLoad.IST". If there is no
  1306.         external IST the internal one is used. The source of the internal
  1307.         IST is included in source representation and can be used to build a
  1308.         external IST. If you encounter missing 68000 instructions in the
  1309.         current IST you are demand to inform the author of WHDLoad to
  1310.         include appropriate extensions in the next WHDLoad release.
  1311.         Due the large exception overhead the execution speed in the selected
  1312.         area will strongly slow down. To improve performance it is therefore
  1313.         recommend to relocate the SSP to a Fast-Memory location using
  1314.         ws_ExpMem and appropriate initialistion and modification of the
  1315.         installed program if required.
  1316.         To maximize performance during the initialisation of this function
  1317.         the BaseMem area will be set to NC, the ExpMem and Slave to CB and
  1318.         all caches will be enabled (resload_SetCPU).
  1319.         Because Resload functions cannot be executed in trace mode, the
  1320.         trace must disabled before and enabled after calling any Resload
  1321.         function following the SMC-detection has been setup (see example).
  1322.  
  1323.  
  1324.    INPUTS
  1325.         length  - size of the memory area to protected
  1326.         address - start address of the memory area to protected
  1327.  
  1328.         the area to protect must be located inside the BaseMem or ExpMem
  1329.  
  1330.    EXAMPLE
  1331.  
  1332.         enable SMC-detection for the area $10000..$3e000:
  1333.                 ...
  1334.                 move.l  #$2e000,d0              ;one longword
  1335.                 lea     $10000,a0               ;address
  1336.                 move.l  (_resload,pc),a2
  1337.                 jsr     (resload_ProtectSMC,a2)
  1338.                 ...
  1339.  
  1340.         load data after enabling the SMC-detection (assumed all time in
  1341.         supervisor mode!):
  1342.                 ...
  1343.                 move    sr,d3                   ;save sr
  1344.                 move    #$2000,sr               ;disable trace mode
  1345.                 move.l  (_resload,pc),a2
  1346.                 jsr     (resload_DiskLoad,a2)
  1347.                 move    d3,sr                   ;restore sr
  1348.                 ...
  1349.  
  1350.    RESULT
  1351.  
  1352.    BUGS
  1353.         Currently supported is only 68030 and 68060. For limitations and
  1354.         restrictions regarding the MMU related part of operation see the BUGS
  1355.         section of resload_ProtectWrite.
  1356.         You must not protect the page where the SSP points to, if you do so
  1357.         an Double Bus Fault will occure because the CPU will be unable to
  1358.         write the exception stackframe, only reset will recover from a Double
  1359.         Bus Fault
  1360.  
  1361.    NOTE
  1362.         requires ws_Version >= 10
  1363.         the MMU must be in use by WHDLoad, otherwise you will get WHDLoad
  1364.         requester "Unacceptible Arguments"
  1365.         there must no resload_Protect* active at the same time
  1366.  
  1367.    SEE ALSO
  1368.         resload_ProtectWrite, resload_SetCPU
  1369.  
  1370. WHDLoad/resload_ProtectWrite
  1371.  
  1372.    NAME
  1373.         resload_ProtectWrite -- mark memory as write protected
  1374.  
  1375.    SYNOPSIS
  1376.         resload_ProtectWrite(length, address)
  1377.                                D0      A0
  1378.                               ULONG   APTR
  1379.  
  1380.    FUNCTION
  1381.         protect the selected area against writing by the processor
  1382.         the area to protect must be located inside BaseMem or ExpMem
  1383.  
  1384.    INPUTS
  1385.         length  - size of the memory area to protected
  1386.         address - start address of the memory area to protected
  1387.  
  1388.    EXAMPLE
  1389.                 ...
  1390.                 moveq   #4,d0                   ;one longword
  1391.                 lea     $64,a0                  ;address
  1392.                 move.l  (_resload,pc),a2
  1393.                 jsr     (resload_ProtectWrite,a2)
  1394.                 ...
  1395.  
  1396.    RESULT
  1397.  
  1398.    BUGS
  1399.         the amount of protected areas is currently limited to 16,
  1400.         the page where the SSP points to must not be protected, because if a
  1401.         Access Fault occurs the CPU will be unable in that case to write the
  1402.         exception stackframe, only reset will recover from the resulting
  1403.         Double Bus Fault
  1404.         limitations on MC68020+MC68851:
  1405.           this hardware is currently not supported
  1406.         limitations on MC68030:
  1407.           - 3-byte transfers are not supported (occuring on misaligned
  1408.             longword accesses to page boundaries eg. "tst.l $fff" (assumed
  1409.             4KByte page size))
  1410.           - locked accesses (tas/cas/cas2) are not supported
  1411.         limitations on MC68040:
  1412.           this hardware is currently not supported
  1413.         limitations on MC68060:
  1414.           - misaligned access are not supported (occuring on accesses trough a
  1415.             page boundary, for example "tst.l ($ffe)" (assumed 4KByte page
  1416.             size))
  1417.           - locked accesses (tas/cas) are not supported
  1418.           - instructions which are located on a protected page and access the
  1419.             supervisor portion of the status register will be executed wrong
  1420.             (these instructions will always see the trace bit as 1 and the
  1421.             interrupt level as 7, any modification of the status register
  1422.             supervisor portion will be without effect)
  1423.           - movem instruction may access a protected area without creating a
  1424.             Access Fault exception (only the first bus cycle of the excution
  1425.             unit will be verified for matching a protected area)
  1426.           - move16 and double precision operations (FPU) are unsupported
  1427.           - a "move (mem),(mem)" with overlapping source and destination
  1428.             address which generates an Access Fault because Misalignment
  1429.             will be executed wrong, for example "move.l ($ffc),($ffe)" where
  1430.             page $1000..$1fff is protected and memory before execution
  1431.             contains ($ffc)=$11112222,($1000)=$33334444, after execution
  1432.             $1000 contains $11114444 and not $22224444)
  1433.         unsupported accesses will result in a "Exception 'Access Fault'"
  1434.         WHDLoad requester
  1435.  
  1436.    NOTE
  1437.         requires ws_Version >= 6
  1438.         the MMU must be in use by WHDLoad, otherwise you will get WHDLoad
  1439.         requester "Unacceptible Arguments".
  1440.         only accesses to the user and supervisor data stream are affected
  1441.         (this means not affected are: CPU space accesses (eg getting values
  1442.         from the vector table) and instruction stream accesses)
  1443.  
  1444.    SEE ALSO
  1445.         resload_ProtectRead, resload_ProtectReadWrite, resload_ProtectRemove
  1446.  
  1447. WHDLoad/resload_Relocate
  1448.  
  1449.    NAME
  1450.         resload_Relocate -- relocate AmigaDOS executable
  1451.  
  1452.    SYNOPSIS
  1453.         size = resload_Relocate(address, tags)
  1454.          D0                       A0      A1
  1455.         ULONG                    APTR   STRUCT
  1456.  
  1457.    FUNCTION
  1458.         relocate an standard AmigaDOS executable in memory
  1459.  
  1460.    INPUTS
  1461.         address - the start address of the executable in memory, this is the
  1462.                   source and also the destination address, i.e.
  1463.                   resload_Relocate will relocates the executable over itself
  1464.                   (a multi pass technique is used)
  1465.         tags    - currently there are no tags so this must be set to NULL
  1466.  
  1467.    EXAMPLE
  1468.                 ...
  1469.                 lea     (_main,pc),a0           ;name
  1470.                 lea     $400,a3                 ;A3 = address for program
  1471.                 move.l  a3,a1                   ;destination
  1472.                 move.l  (_resload,pc),a2
  1473.                 jsr     (resload_LoadFileDecrunch,a2)
  1474.                 move.l  a3,a0                   ;address
  1475.                 sub.l   a1,a1                   ;tags
  1476.                 jsr     (resload_Relocate,a2)
  1477.                 ...
  1478.                 jmp     (a3)                    ;start the program
  1479.                 ...
  1480.  
  1481.         _main   dc.b    "main-program",0
  1482.  
  1483.    RESULT
  1484.         size - size of the relocated executable
  1485.                (this may be more or less than the size of the executable file,
  1486.                depending on BSS hunks contained in the executable)
  1487.  
  1488.    BUGS
  1489.         the routine supports all hunks supported by Kickstart 1.3 except
  1490.         OVERLAY, anyway it is only tested with a limited amount of
  1491.         executables, so please report any problems or bugs
  1492.  
  1493.    NOTE
  1494.         the function uses stack for variables, the amount depends on the
  1495.         number of hunks in the executable and can be calculated as
  1496.         "used stack = hunks * 16 + 32"
  1497.         currently the executable must not contain more than 256 hunks (also
  1498.         AmigaDOS allows not more than 256 hunks)
  1499.         the routine performs automatically a resload_FlushCache before
  1500.         returning
  1501.  
  1502.    SEE ALSO
  1503.  
  1504. WHDLoad/resload_SaveFile
  1505.  
  1506.    NAME
  1507.         resload_SaveFile -- write memory to a file
  1508.  
  1509.    SYNOPSIS
  1510.         success,errorcode = resload_SaveFile(size, name, address)
  1511.           D0       D1                         D0    A0      A1
  1512.          BOOL     ULONG                     ULONG  CPTR    APTR
  1513.  
  1514.    FUNCTION
  1515.         write specified memory area to file using specified name
  1516.  
  1517.    INPUTS
  1518.         size    - amount of bytes to write
  1519.         name    - name of file to write
  1520.         address - memory address of buffer to write
  1521.  
  1522.    EXAMPLE
  1523.                 ...
  1524.                 move.l  #512,d0                 ;size
  1525.                 lea     (_save,pc),a0           ;name
  1526.                 lea     $5ac20,a1               ;source
  1527.                 move.l  (_resload,pc),a2
  1528.                 jsr     (resload_SaveFile,a2)
  1529.                 ...
  1530.  
  1531.         _save   dc.b    "saved",0
  1532.  
  1533.    RESULT
  1534.         success   - TRUE on success
  1535.         errorcode - 0 on success
  1536.                     otherwise a dos-errorcode from dos.IoErr()
  1537.         if WHDLF_NoError is set, the function only returns on success
  1538.  
  1539.    BUGS
  1540.  
  1541.    NOTE
  1542.  
  1543.    SEE ALSO
  1544.         resload_SaveFileOffset
  1545.  
  1546. WHDLoad/resload_SaveFileOffset
  1547.  
  1548.    NAME
  1549.         resload_SaveFileOffset -- write memory to a file at offset
  1550.  
  1551.    SYNOPSIS
  1552.         success,error = resload_SaveFileOffset(size, offset, name, address)
  1553.           D0     D1                             D0     D1     A0      A1
  1554.          BOOL   ULONG                          ULONG  ULONG  CPTR    APTR
  1555.  
  1556.    FUNCTION
  1557.         write specified memory area to file at specified offset using
  1558.         specified name
  1559.  
  1560.    INPUTS
  1561.         size    - amount of bytes to write
  1562.         offset  - offset in the file to write
  1563.         name    - name of file to write
  1564.         address - memory address of buffer to write
  1565.  
  1566.    EXAMPLE
  1567.                 ...
  1568.                 move.l  #512,d0                 ;size
  1569.                 move.l  #$4000,d1               ;offset
  1570.                 lea     (_save,pc),a0           ;name
  1571.                 lea     $5ac20,a1               ;source
  1572.                 move.l  (_resload,pc),a2
  1573.                 jsr     (resload_SaveFileOffset,a2)
  1574.                 ...
  1575.  
  1576.         _save   dc.b    "saved",0
  1577.  
  1578.    RESULT
  1579.         success   - TRUE on success
  1580.         errorcode - 0 on success
  1581.                     otherwise a dos-errorcode from dos.IoErr()
  1582.         if WHDLF_NoError is set, the function only returns on success
  1583.  
  1584.    BUGS
  1585.  
  1586.    NOTE
  1587.         requires ws_Version >= 5
  1588.  
  1589.    SEE ALSO
  1590.         resload_SaveFile
  1591.  
  1592. WHDLoad/resload_SetCACR
  1593.  
  1594.    NAME
  1595.         resload_SetCACR -- set cachebility for BaseMem
  1596.  
  1597.    SYNOPSIS
  1598.         old = resload_SetCACR(new, mask)
  1599.          D0                    D0   D1
  1600.        ULONG                 ULONG ULONG
  1601.  
  1602.    FUNCTION
  1603.         modifies the cachebility for BaseMem, using this routine the
  1604.         instruction and the data cache can be enabled and disabled,
  1605.         the changes will affect the CACR (Cache Control Register) and
  1606.         the MMU-tables if it is used by WHDLoad
  1607.  
  1608.    INPUTS
  1609.         new  - new cache status
  1610.         mask - status bits to change
  1611.  
  1612.         valid values for new and mask are:
  1613.                 CACRF_EnableI - instruction cache
  1614.                 CACRF_EnableD - data cache
  1615.         (bits are defined in the standard include file "exec/execbase.i")
  1616.  
  1617.    EXAMPLE
  1618.         to enable instruction cache:
  1619.                 ...
  1620.                 move.l  #CACRF_EnableI,d0       ;new status
  1621.                 move.l  d0,d1                   ;status to change
  1622.                 move.l  (_resload,pc),a2
  1623.                 jsr     (resload_SetCACR,a2)
  1624.                 ...
  1625.  
  1626.    RESULT
  1627.         old - old cache status
  1628.  
  1629.    BUGS
  1630.  
  1631.    NOTE
  1632.         it is safe to call this routine from User or Supervisor mode and
  1633.         independend from the actual CPU type (also on 68000/010)
  1634.         if WHDLoad is launched with the option NoCache/S this routine will
  1635.         return without changing anything (BaseMem is always noncacheable)
  1636.         don't wonder if you see in the coredump or in a freezer that caches
  1637.         are enabled even if not enabled by the Slave: if the MMU is used by
  1638.         WHDLoad and no caches are switched on by the Slave, WHDLoad marks the
  1639.         BaseMem using the MMU as noncacheable-serialized, and enables both
  1640.         caches so that the memory of WHDLoad and the Slave are cachable to
  1641.         increase performance
  1642.         the routine performs automatically a resload_FlushCache before
  1643.         returning
  1644.  
  1645.    SEE ALSO
  1646.         resload_SetCPU, resload_FlushCache
  1647.  
  1648. WHDLoad/resload_SetCPU
  1649.  
  1650.    NAME
  1651.         resload_SetCPC -- control CPU setup
  1652.  
  1653.    SYNOPSIS
  1654.         old = resload_SetCPU(new, mask)
  1655.          D0                   D0   D1
  1656.        ULONG                ULONG ULONG
  1657.  
  1658.    FUNCTION
  1659.         change cachebility of memory areas and change the CPU setup
  1660.         see include file "whdload.i" for supported bit sets
  1661.  
  1662.    INPUTS
  1663.         new  - new setup
  1664.         mask - parts of the current setup to change
  1665.  
  1666.    EXAMPLE
  1667.         to enable the only instruction cache for BaseMem and ExpMem:
  1668.                 ...
  1669.                 move.l  #WCPUF_Base_WT|WCPUF_Exp_CB|WCPUF_IC,d0
  1670.                 move.l  #WCPUF_Base|WCPUF_Exp|WCPUF_IC|WCPUF_DC,d1
  1671.                 move.l  (_resload,pc),a2
  1672.                 jsr     (resload_SetCPU,a2)
  1673.                 ...
  1674.  
  1675.    RESULT
  1676.         old - the setup before
  1677.  
  1678.    BUGS
  1679.  
  1680.    NOTE
  1681.         it is safe to call this routine from User or Supervisor mode and
  1682.         independend from the actual CPU type (also on 68000/010)
  1683.         if WHDLoad is launched with the option NoCache/S this routine will
  1684.         return without changing anything
  1685.         don't wonder if you see in the coredump or in a freezer that caches
  1686.         are enabled even if not enabled by the Slave: if the MMU is used by
  1687.         WHDLoad and no caches are switched on by the Slave, WHDLoad marks the
  1688.         memory of the installed program using the MMU as noncacheable-
  1689.         serialized, and enables both caches so that the memory of WHDLoad is
  1690.         cachable to increase performance
  1691.         the routine performs automatically a resload_FlushCache before
  1692.         returning
  1693.  
  1694.    SEE ALSO
  1695.  
  1696.  
  1697. WHDLoad.Slave/--Overview--
  1698.  
  1699. The WHDLoad.Slave contains the interface code which makes the installed
  1700. program able to load his files from harddisk. Additional it should realize
  1701. the possibility to quit the program to return to the OS.
  1702.  
  1703.    FORMAT
  1704.         is a standard amiga executable
  1705.    ATTENTION
  1706.         the Slave MUST consist of only ONE hunk (ONE section)
  1707.         the Slave MUST be 100% PC-relative
  1708.  
  1709.    STRUCTURE
  1710.         at the top of the Slave is "WHDLoadSlave" structure, after this
  1711.         follows the specific code and data
  1712.  
  1713.              STRUCTURE  WHDLoadSlave,0
  1714.                 STRUCT  ws_Security,4
  1715.                 STRUCT  ws_ID,8
  1716.                 UWORD   ws_Version
  1717.                 UWORD   ws_Flags
  1718.                 ULONG   ws_BaseMemSize
  1719.                 ULONG   ws_ExecInstall
  1720.                 RPTR    ws_GameLoader
  1721.                 RPTR    ws_CurrentDir
  1722.                 RPTR    ws_DontCache
  1723.              (  LABEL   ws_SIZEOF_pre_v4  )
  1724.                 UBYTE   ws_keydebug
  1725.                 UBYTE   ws_keyexit
  1726.              (  LABEL   ws_SIZEOF_pre_v8  )
  1727.                 ULONG   ws_ExpMem
  1728.              (  LABEL   ws_SIZEOF_pre_v10 )
  1729.                 RPTR    ws_name
  1730.                 RPTR    ws_copy
  1731.                 RPTR    ws_info
  1732.                 LABEL   ws_SIZEOF
  1733.  
  1734.         ws_Security
  1735.                 the code
  1736.                         moveq #-1,d0
  1737.                         rts
  1738.                 to avoid problems if somebody tries execute the Slave directly
  1739.  
  1740.         ws_ID
  1741.                 the string "WHDLOADS" to identify the program as a Slave
  1742.  
  1743.         (use the macro SLAVE_HEADER defined in the include file "whdload.i" to
  1744.         create the entries ws_Security and ws_ID)
  1745.  
  1746.         ws_Version
  1747.                 the version of WHDLoad that is required by the Slave,
  1748.                 some resload functions need at least a specific version of
  1749.                 WHDLoad, e.g. to use resload_CRC16 you must set ws_Version
  1750.                 to 3 or higher
  1751.                 on the other side the size of the WHDLoadSlave structure
  1752.                 differs for different Slave versions, e.g. if you set
  1753.                 ws_Version to 4 or higher you MUST initialize the fields
  1754.                 ws_keydebug and ws_keyexit and so on
  1755.  
  1756.         ws_Flags
  1757.                 WHDLF_Disk / WHDLB_Disk
  1758.                    this flag should enabled if the program uses
  1759.                    disk images (the result is a different working Preload/S)
  1760.                    (starting WHDLoad 0.143 this flag is obsolete)
  1761.                 WHDLF_NoError / WHDLB_NoError
  1762.                    if enabled every error occuring in a resload_#? function
  1763.                    lets WHDLoad immedately quit, and prompt an error requester
  1764.                    about the reason
  1765.                    using this flag it is not neccessary that the Slave checks
  1766.                    the return code resload_#? functions, it can be sure that
  1767.                    if a function returns it was successful (this will make the
  1768.                    Slave more simple)
  1769.                 WHDLF_EmulTrap / WHDLB_EmulTrap
  1770.                    this flag has only effect if the VBR is moved by WHDLoad
  1771.                    (i.e. the machine is at least a 68010 and the tooltype
  1772.                    NoVBRMove is not set)
  1773.                    if the flag is set all "trap #0..15"'s are emulated by the
  1774.                    exception handler in WHDLoad like the autovectors, i.e.
  1775.                    the handler checks if the vector ($80-$bc) is initialized
  1776.                    by the program, and if it is the routine will be called by
  1777.                    the handler
  1778.                 WHDLF_NoDivZero / WHDLB_NoDivZero
  1779.                    this flag has only effect if the VBR is moved by WHDLoad
  1780.                    (i.e. the machine is at least a 68010 and the tooltype
  1781.                    NoVBRMove is not set)
  1782.                    if the flag is set and a "Division by Zero" exception
  1783.                    occurs WHDLoad will not quit with an requester, but a
  1784.                    RTE will be performed
  1785.                    this maybe useful if you don't want use the option
  1786.                    NoVBRMove but the demo/game performs divisions by zero
  1787.                 WHDLF_Req68020 / WHDLB_Req68020
  1788.                    this flag indicates that the Slave/installed program
  1789.                    requires at least a MC68020 CPU, WHDLoad will check at
  1790.                    startup if this requirement matches, if it doesn't the
  1791.                    program will be terminated with an appropriate requester
  1792.                 WHDLF_ReqAGA / WHDLB_ReqAGA
  1793.                    this flag indicates that the Slave/installed program
  1794.                    requires at least the AGA chipset, WHDLoad will check at
  1795.                    startup if this requirement matches, if it doesn't the
  1796.                    program will be terminated with an appropriate requester
  1797.                 WHDLF_NoKbd / WHDLB_NoKbd
  1798.                    this flag says WHDLoad, that it doesn't should reply the
  1799.                    keyboard if a key was pressed, this must be used with
  1800.                    programs which doesn't check the keyboard from the PORTS
  1801.                    interrupt ($68), background: in normal operation when
  1802.                    NoVBRMove is inactive, WHDLoad checks if a key was pressed
  1803.                    on each interrupt, if a key has been pressed it checks the
  1804.                    rawkey code against QuitKey, DebugKey and FreezeKey, if it
  1805.                    doesn't match it looks if there is a initialized PORTS
  1806.                    interrupt ($68), if there is no, it replies the keyboard
  1807.                    that the keycode has been received, therefore the installed
  1808.                    program if it checks the keyboard from e.g. the VBI will
  1809.                    never receive any keycode, this flag avoids this behavior
  1810.                 WHDLF_EmulLineA / WHDLB_EmulLineA
  1811.                    this flag has only effect if the VBR is moved by WHDLoad
  1812.                    (i.e. the machine is at least a 68010 and the tooltype
  1813.                    NoVBRMove is not set)
  1814.                    if the flag is set all exceptions "Line-A" (caused by
  1815.                    opcodes starting with %1010) are emulated by the
  1816.                    exception handler in WHDLoad like the autovectors, i.e.
  1817.                    the handler checks if the vector ($28) is initialized
  1818.                    by the program, and if it is the routine which the vector
  1819.                    points to will be called by the handler
  1820.                 WHDLF_EmulTrapV / WHDLB_EmulTrapV
  1821.                    this flag has only effect if the VBR is moved by WHDLoad
  1822.                    (i.e. the machine is at least a 68010 and the tooltype
  1823.                    NoVBRMove is not set)
  1824.                    if the flag is set all exceptions caused by a TrapV
  1825.                    instruction are emulated by the exception handler in
  1826.                    WHDLoad like the autovectors, i.e. the handler checks if
  1827.                    the vector ($1C) is initialized by the program, and if it
  1828.                    is the routine which the vector points to will be called
  1829.                    by the handler
  1830.  
  1831.         ws_BaseMemSize
  1832.                 the size of the memory that is required by the program
  1833.                 the BaseMemory starts an $00000000 and ends at ws_BaseMemSize
  1834.                 (BaseMemory is always ChipMem)
  1835.                 this value must be multiple of $1000
  1836.                 the valid minimum is $2000, the maximum $200000
  1837.  
  1838.         ws_ExecInstall
  1839.                 obsolete, must be set to 0
  1840.  
  1841.         ws_GameLoader
  1842.                 a relative (to the start of the structure) 16-bit pointer
  1843.                 to the start code of the Slave
  1844.  
  1845.         ws_CurrentDir
  1846.                 a relative (to the start of the structure) 16-bit pointer
  1847.                 to a 0 terminated string which is the name of the path
  1848.                 where all files are stored (sub directory)
  1849.                 if no sub directory is used initialize this with 0
  1850.                 WHDLoad will change into this directory on startup
  1851.                 the path must be relative; you MUST NOT use any fucking lame
  1852.                 assignments
  1853.             BACKGROUND: if the assignment is not active on runtime the
  1854.                 dos.library will try to show a "Insert Disk ..." requester,
  1855.                 but intuition.library is locked, -> the system will hang
  1856.                 (deadlock) the user has only one alternative -> REBOOT
  1857.  
  1858.         ws_DontCache
  1859.                 a relative (to the start of the structure) 16-bit pointer
  1860.                 to a 0 terminated string which is a standard AmigaDOS
  1861.                 pattern (dos.ParsePattern, dos.MatchPattern)
  1862.                 all files matching this pattern are not cached by WHDLoad
  1863.                 this may be useful for savegames
  1864.                 if you dont want to use set the entry to 0
  1865.                 starting WHDLoad version 0.107 this is obsolete, because saved
  1866.                 files will be written also to the file cache
  1867.  
  1868.       the following variables are only evaluated by WHDLoad if ws_Version
  1869.       is set to >= 4
  1870.       the following variables MUST be initialized if you set ws_Version
  1871.       to >= 4
  1872.  
  1873.         ws_keydebug
  1874.                 the raw key code to exit with debug
  1875.                 this variable will be overwritten by WHDLoad if the option
  1876.                 DebugKey= is set in the global config or as CLI argument or
  1877.                 ToolType with the specified value from there
  1878.                 if the Slave provides an own handler to support a debug option
  1879.                 via the keyboard it should use this entry for comparision, so
  1880.                 it will be possible for the user to change the default key
  1881.                 suggestion from the Slave
  1882.                 this entry is also used by WHDLoad's internal handler if the
  1883.                 VBR is moved (requires 68010+ and that NoVBRMove is not set)
  1884.                 (recommend is $58 = "F9")
  1885.  
  1886.         ws_keyexit
  1887.                 the raw key code to exit
  1888.                 similar to ws_keydebug
  1889.                 (recommend is $59 = "F10")
  1890.  
  1891.       the following variables are only evaluated by WHDLoad if ws_Version
  1892.       is set to >= 8
  1893.       the following variables MUST be initialized if you set ws_Version
  1894.       to >= 8
  1895.  
  1896.         ws_ExpMem
  1897.                 if the installed program requires expansion memory, the size
  1898.                 must be specified here, WHDLoad will allocate a memory block
  1899.                 of this size and writes a pointer to the start of the
  1900.                 allocated memory back to this entry, the memory is granted to
  1901.                 be aligned to $1000 (4096 bytes), the size specified must be
  1902.                 an multiple of $1000 (4096), if WHDLoad fails to allocate
  1903.                 this memory it terminates with an appropriate error requester,
  1904.                 that means the Slave will always get a valid pointer here
  1905.                 - starting WHDLoad version 10.2 the value can be negative,
  1906.                 which means that the memory is optional and not absolute
  1907.                 required, WHDLoad will try to allocate it and if it fails it
  1908.                 will set ws_ExpMem to zero, the Slave has to check ws_ExpMem
  1909.                 therefore
  1910.  
  1911.       the following variables are only evaluated by WHDLoad if ws_Version
  1912.       is set to >= 10
  1913.       the following variables MUST be initialized if you set ws_Version
  1914.       to >= 10
  1915.  
  1916.         ws_name
  1917.                 a relative (to the start of the structure) 16-bit pointer
  1918.                 to a 0 terminated string containing the name of the installed
  1919.                 program, e.g. "Super Hang Off"
  1920.         ws_copy
  1921.                 a relative (to the start of the structure) 16-bit pointer
  1922.                 to a 0 terminated string containing the copyright of the
  1923.                 installed program, the string should start with the year
  1924.                 followed by the company holding the copyright, multiple years
  1925.                 or companies should be separated with ", "
  1926.                 e.g. "1983 Schega, 1989 Bad Dreams"
  1927.         ws_info
  1928.                 a relative (to the start of the structure) 16-bit pointer
  1929.                 to a 0 terminated string containing addional infos about the
  1930.                 installed program, the string may also contain line feeds
  1931.                 ($0a), the character -1 has a special meaning - it results in
  1932.                 a line feed and an additional vertical skip of the half font
  1933.                 height, e.g.:
  1934.                         dc.b    "installed & fixed by Wepl",10
  1935.                         dc.b    "version 1.4 (06.06.2066)",-1
  1936.                         dc.b    "greetings to the world",0
  1937.  
  1938.  
  1939.    CONVENTIONS for ws_GameLoader
  1940.         the status of the system at the moment of calling ws_GameLoader:
  1941.  
  1942.         CPU:
  1943.                 SR   = $2000           Supervisor-mode, all interrupts enabled
  1944.                 SSP  = ws_BaseMemSize  at end of BaseMem
  1945.                 USP  = SSP-$400        at end of BaseMem - 1024
  1946.                 A0   = ResidentLoader  pointer to the resident Jump-Tower
  1947.                 D0-D7/A1-A6 random     (D0=$d0d0d0d0 D1=...)
  1948.  
  1949.                 nothing more is interesting from the Slave programmes point of
  1950.                 view, all special registers like VBR,SFC,DFC,CAAR,CACR,MSP,TC,
  1951.                 MMUSR,CRP,SRP,URP,TT0,TT1,DTT0,DTT1,ITT0,ITT1,PCR,BUSCR are
  1952.                 WHDLoad private and MUST NOT BE CHANGED.
  1953.  
  1954.         BaseMem:
  1955.                 $00000000 = 0
  1956.                 $00000004 = $f0000001  any try to use the execbase should
  1957.                                        create a "Address Error" exception
  1958.                 $00000008 - $00000400
  1959.                           = $CCCCCCCC  if WHDLoad has moved the VBR else
  1960.                           = Handler    the address of a exception handler
  1961.                                        inside WHDLoad
  1962.                 $00000400 - ws_BaseMemSize
  1963.                           = $CCCCCCCC  this memory fill pattern is used to
  1964.                                        easy recognize modified memory
  1965.                 $00001000 = $FFFFFFFE  the copper instruction "CWAIT $ff,$1fe"
  1966.  
  1967.         ExpMem:
  1968.                 the memory is filled with the pattern "$DDDDDDDD"
  1969.  
  1970.         custom:
  1971.                 dmacon = 0             all dma's off
  1972.                 intena = 0             all interrupts off
  1973.                 cop1lc = cop2lc = $1000
  1974.                 a AGA-machine is switched to OCS
  1975.  
  1976.         cia's:
  1977.                 ------- ciaa ------     ------- ciab ------
  1978.                 pra in  = %00000000     pra in  = %00000000
  1979.                 pra out = %11111100     pra out = %11111000
  1980.                 ddra    = %00000011     ddra    = %11000000
  1981.                 prb in  = %00000000     prb in  = %00000000
  1982.                 prb out = %00000000     prb out = %11111111
  1983.                 ddrb    = %00000000     ddrb    = %11111111
  1984.                 ta      =     $21ff     ta      =     $ffff
  1985.                 tb      =     $21ff     tb      =     $ffff
  1986.                 event   =   $000000     event   =   $000000
  1987.                 alarm   =   $ffffff     alarm   = execbase.EClockFrequency
  1988.                 sdr     =       $00     sdr     =       $00
  1989.                 icr     = %00000000     icr     = %00000000
  1990.                 icm     = %00001000     icm     = %00000000
  1991.                 cra     = %00000000     cra     = %00000000
  1992.                 crb     = %00000000     crb     = %00000000
  1993.  
  1994.    SEE ALSO
  1995.         example Slaves
  1996.  
  1997.